<%--
  Created by IntelliJ IDEA.
  User: leixiaolong
  Date: 2018/9/20
  Time: 下午5:12
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/include.jsp" %>

<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" href="/static/css/rpt-condition.css" media="all" type="text/css">

    <style>
        .layui-form-label {
            width: 160px !important;
        }
    </style>

    <style>
        /* 防止下拉框的下拉列表被隐藏---必须设置--- */
        .layui-table-cell {
            overflow: visible !important;
        }

        /* 使得下拉框与单元格刚好合适 */
        td .layui-form-select {
            /*margin-top: -10px;*/
            /*margin-left: -15px;*/
            /*margin-right: -15px;*/
            /*solid: #d2d2d2;*/
            /*border: 1px;*/
        }

        /* 设置下拉框的高度与表格单元相同 */
        .layui-input, .layui-select, .layui-textarea {
            height: 30px !important;
        }

    </style>

    <style>
        .col-select-lg {
            margin-top: 10px;
            height: 30px;
            width: 300px;
            min-width: 200px;
            max-width: 600px;
        }

        .layui-input-inline {
            min-width: 300px;
            max-width: 600px;
        }
    </style>
</head>
<body class="layui-bg-gray">
<div class="layui-row layui-col-space10" style="margin: 10px; background-color: white">
    <div class="layui-container">
        <div class="layui-row layui-form">
            <div class="layui-col-md6 ">
                <div class="layui-form-item">
                    <label class="layui-form-label ">客户编码：</label>
                    <div class="layui-input-inline">
                        <input type="text" id="cust_code" disabled class="layui-input-inline dom-add-input">
                    </div>
                </div>
            </div>
            <div class="layui-col-md6">
                <div class="layui-form-item">
                    <label class="layui-form-label">客户名称：</label>
                    <input type="text" id="cust_name" disabled class="layui-input-inline dom-add-input">
                </div>
            </div>
            <div class="layui-col-md6">
                <div class="layui-form-item">
                    <label class="layui-form-label">客户简称：</label>
                    <input type="text" id="abbr_name" disabled class="layui-input-inline dom-add-input">
                </div>
            </div>
            <div class="layui-col-md6">
                <div class="layui-form-item">
                    <label class="layui-form-label">公司营业执照号：</label>
                    <input type="text" id="organ_license" disabled class="layui-input-inline dom-add-input">
                </div>
            </div>
            <div class="layui-col-md6">
                <div class="layui-form-item">
                    <label class="layui-form-label">公司法人名称：</label>
                    <input type="text" id="legal_name" disabled class="layui-input-inline dom-add-input">
                </div>
            </div>
            <div class="layui-col-md6">
                <div class="layui-form-item">
                    <label class="layui-form-label">公司法人证件类型：</label>
                    <div class="layui-input-inline">
                        <select class="layui-form-select" disabled id="cert_type" lay-filter="sour_sale_type">
                            <option value="" selected>全部</option>
                            <option value="1" >身份证</option>
                            <option value="2" >军人证</option>
                            <option value="3" >护照</option>
                            <option value="4" >户口本</option>
                            <option value="8" >工商营业执照</option>
                            <option value="9" >法人代码证</option>
                            <option value="18" >其他</option>
                        </select>
                    </div>
                </div>
            </div>
            <div class="layui-col-md6">
                <div class="layui-form-item">
                    <label class="layui-form-label">公司注册地址：</label>
                    <input type="text" id="address" disabled class="layui-input-inline dom-add-input">
                </div>
            </div>
            <div class="layui-col-md6">
                <div class="layui-form-item">
                    <label class="layui-form-label">合同到期日：</label>
                    <div class="layui-input-inline">
                        <input type="text" id="due_date" disabled class="layui-input-inline dom-add-input">
                    </div>
                </div>
            </div>
            <div class="layui-col-md6">
                <div class="layui-form-item">
                    <label class="layui-form-label">客户类型：</label>
                    <div class="layui-input-inline">
                        <select class="layui-form-select" disabled id="cust_type" lay-filter="cust_type">
                            <option value="" selected>全部</option>
                        </select>
                    </div>
                </div>
            </div>
            <div class="layui-col-md6">
                <div class="layui-form-item">
                    <label class="layui-form-label">客户等级：</label>
                    <div class="layui-input-inline">
                        <select class="layui-form-select" disabled id="cust_level" lay-filter="cust_level">
                            <option value="" selected>全部</option>
                            <option value="1" selected>vip客户</option>
                            <option value="2" selected>普通客户</option>
                        </select>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div style="margin: 10px; background-color: white;">
    <table class="layui-hide" id="tab_cust_detail" lay-filter="cust-add-filter"></table>
</div>

<div class="layui-btn-container" style="float: right; margin-right: 10%">
    <button class="layui-btn layui-btn-normal layui-btn-warm" lay-submit data-type="cancel">取消</button>
</div>
</body>

<script language='javascript' src="${pageContext.request.contextPath}/static/js/component/form-select.js"></script>
<script language='javascript' src="${pageContext.request.contextPath}/static/js/component/table-data.js"></script>
<script language='javascript' src="${pageContext.request.contextPath}/static/js/utils/tax-math.js"></script>
<script language='javascript' src="${pageContext.request.contextPath}/static/js/utils/base-data.js"></script>
<script language='javascript' src="${pageContext.request.contextPath}/static/js/utils/base-math.js"></script>
<script language='javascript' src="${pageContext.request.contextPath}/static/js/component/form-select.js"></script>
<script language='javascript' src="${pageContext.request.contextPath}/static/js/component/form-date.js"></script>
<script language='javascript' src="${pageContext.request.contextPath}/static/js/utils/moment.js"></script>
<script>

    layui.use(["element", "form", "layer", "table", "jquery", "laydate"], function () {
        var element = layui.element, layer = layui.layer, table = layui.table, $ = layui.jquery;
        var form = layui.form;
        var params = {
            sysCode : '28'
        }
        initCodeTableSelect("cust_type","/base/getSysCodeList",params);

        table.set({
            limit: 50
        });
        var tableIns = table.render({
            id: 'tab_cust_detail',
            elem: '#tab_cust_detail',
            toolbar: '#toolbarAdd',
            defaultToolbar: [],
            cellMinWidth: 90,
            data: [],
            height: 'full-350',
            cols: [[
                { field: 'id', title: '序号', align: 'center' },
                { field: 'keyId', title: '流水序号', align: 'center', hide: true },
                {field: 'contName', title: '联系人名称', align: 'center'},
                {field: 'contPhone', title: '联系人电话', align: 'center'},
                {field: 'contSex', title: '联系人性别', align: 'center'},
                {field: 'level', title: '联系人优先级', align: 'center'}]]
        });

        active = {
            cancel: function cancel() {
                layer.msg("关闭弹出客户信息明细");
                var parent_layer = parent.layer;
                var index = parent.layer.getFrameIndex(window.name); //获取当前窗体索引
                parent.layer.close(index);
                parent.layui.table.reload("tab_cust_apply", {});
            }
        };

        form.on('submit', function (data) {
            var elem = data.elem;
            active[$(this).data("type")].call(this, elem);
        });
    });

    function init(paramData) {
        var params = {id: paramData.id};
        debugger;
        layui.use(["form", "jquery","table", "laydate"], function () {
            var form = layui.form, $ = layui.jquery, table = layui.table, laydate = layui.laydate;
            $.ajax({
                url: "/base/updateCustInfoPage",
                type: 'POST',
                sync: false,
                data: params,
                success: function (data) {
                    $('#key_id').val(data.data.id);
                    $('#cust_code').val(data.data.custCode);
                    $('#cust_name').val(data.data.custName);
                    $('#abbr_name').val(data.data.abbrName);
                    $('#organ_license').val(data.data.organLicense);
                    $('#legal_name').val(data.data.legalName);
                    $('#cert_type').val(data.data.certType);
                    $('#cert_no').val(data.data.certNo);
                    renderDate('due_date',data.data.dueDate);
                    $('#address').val(data.data.address);
                    $('#cust_type').val(data.data.custType);
                    $('#cust_level').val(data.data.custLevel);
                    form.render('select');
                    var list = data.data.custLinkData;
                    var newdata = table.cache["tab_cust_detail"];
                    $.each(list, function (i, n) {  //回显到表格
                        var newline = {
                            'id': i,
                            'keyId': list[i].id,
                            'contName': list[i].contName,
                            'contPhone': list[i].contPhone,
                            'contSex': list[i].contSex,
                            'level': list[i].level,
                        };
                        newdata.push(newline);//右侧加入
                    });
                    table.reload("tab_cust_detail", {
                        data: newdata
                    });
                    layer.msg("交易成功,页面渲染完成！");
                },
                fail: function (data) {
                    layer.msg("交易失败, message:" + data.rspMsg)
                }
            });
        });
    }
</script>
</html>
